@extends('layouts._admin')

@section('title')
    商品列表
@endsection

@section('content')
    <div class="app-content">
        <div ui-butterbar></div>
        <a href class="off-screen-toggle hide" data-toggle="class:off-screen" data-target=".app-aside"></a>
        <div class="app-content-body fade-in-up">
            <!-- COPY the content from "tpl/" -->
            <div class="hbox hbox-auto-xs hbox-auto-sm">
                <div class="col">
                    <div class="wrapper-md ng-scope">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                商品列表
                            </div>
                            <div class="table-responsive">
                                <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                                    <div class="panel-body">
                                        @if ($message = Session::get('success'))
                                            <div class="alert alert-success">
                                                <p>{{ $message }}</p>
                                            </div>
                                        @endif

                                        @if ($message = Session::get('error'))
                                            <div class="alert alert-danger">
                                                <p>{{ $message }}</p>
                                            </div>
                                        @endif


                                        <a style="float: left;margin-right: 10px;" href="{{route('goods.excel.create')}}">
                                            <button type="button" class="btn btn-sm btn-primary">
                                                <i class="glyphicon glyphicon-plus"></i>
                                                Excel导入商品
                                            </button>
                                        </a>

                                        <a style="float: left;margin-right: 10px;" href="{{route('goods.delete.repeatGoods')}}">
                                            <button type="button" class="btn btn-sm btn-info">
                                                删除重复商品
                                            </button>
                                        </a>

                                        <a style="float: left;margin-right: 10px;" href="{{route('goods.delete.expiredGoods')}}">
                                            <button type="button" class="btn btn-sm btn-info">
                                                删除优惠码过期商品
                                            </button>
                                        </a>

                                        <a style="float: right;margin-right: 10px;" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#myModal1" href="javascript:;">删除当天索引</a>

                                        <a style="float: right;margin-right: 10px;" class="btn btn-sm btn-info" data-toggle="modal" data-target="#myModal2" href="javascript:;">更新当天索引</a>

                                        <a style="float: right;margin-right: 10px;" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#myModal3" href="javascript:;">删除当天数据</a>

                                        {{--<a href="{{route('goods.update.upload')}}">--}}
                                            {{--<button type="button" class="btn btn-sm btn-info">--}}
                                                {{--更新当天上传商品索引--}}
                                            {{--</button>--}}
                                        {{--</a>--}}

                                    </div>
                                    <div class="row">

                                        <div class="col-sm-12">
                                            <table ui-jq="dataTable" ui-options="{sAjaxSource: 'api/datatable.json',aoColumns: [{ mData: 'engine' },{ mData: 'browser' },{ mData: 'platform' },{ mData: 'version' },{ mData: 'grade' }]}" class="table table-striped b-t b-b dataTable no-footer" id="DataTables_Table_0" role="grid" aria-describedby="DataTables_Table_0_info">
                                                <thead>
                                                <tr role="row">
                                                    <th style="width: 100px;" class="sorting" tabindex="0"
                                                        aria-controls="DataTables_Table_0" rowspan="1" colspan="1">序号</th>
                                                    <th style="width: 250px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">商品名字</th>
                                                    <th style="width: 100px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">商品价格</th>
                                                    <th style="width: 100px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">月销量</th>
                                                    <th style="width: 100px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">佣金</th>
                                                    <th style="width: 150px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">店铺名称</th>
                                                    <th style="width: 100px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">类型</th>
                                                    <th style="width: 100px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">优惠面额</th>
                                                    <th style="width: 100px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">优惠结束</th>
                                                    <th style="width: 150px;" class="sorting" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1">商品创建</th>

                                                    <th style="width: 243px;" class="sorting" tabindex="0"
                                                        aria-controls="DataTables_Table_0" rowspan="1" colspan="1">操作</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                @foreach($goods as $id => $good)
                                                    <tr role="row" class="odd">
                                                        <td>{{$good->id}}</td>
                                                        <td>{{$good->goods_name}}</td>
                                                        <td>{{$good->goods_price}}</td>
                                                        <td>{{$good->month_sales}}</td>
                                                        <td>{{$good->commission}}</td>
                                                        <td>{{$good->shop_name}}</td>
                                                        <td>{{$good->platform}}</td>
                                                        <td>{{$good->coupon_name}}</td>
                                                        <td>{{$good->coupon_etime}}</td>
                                                        <td>{{$good->created_at}}</td>
                                                        <td>
                                                            <a class="btn btn-info" target="_blank" href="{{$good->coupon_market_link}}">领卷</a>
                                                            {!! Form::open(['method' => 'DELETE','route' => ['goods.destroy', $good->id],'style'=>'display:inline']) !!}
                                                            {!! Form::submit('删除', ['class' => 'btn btn-danger']) !!}
                                                            {!! Form::close() !!}
                                                        </td>
                                                    </tr>
                                                @endforeach
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <div class="dataTables_info text-height" id="DataTables_Table_0_info"
                                                 role="status" aria-live="polite">当前第{{$goods->currentPage()}}页,
                                                共{{$goods->total()}}个条目</div>
                                        </div>
                                        <div class="col-sm-6">
                                            {!! $goods->render() !!}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        删除xunsearch当天索引
                    </h4>
                </div>
                <div class="modal-body">
                    注:确定后 删除xunsearch当天索引 (时间稍长,请耐心等待)

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <a class="btn btn-danger"  href="{{route('goods.delete.upload')}}">删除</a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        更新xunsearch当天索引
                    </h4>
                </div>
                <div class="modal-body">
                    注:确定后 更新xunsearch当天索引 (时间稍长,请耐心等待) 分几页操作

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <a class="btn btn-danger"  href="{{route('goods.update.upload')}}">更新</a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>


    <div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        删除MYSQL当天数据
                    </h4>
                </div>
                <div class="modal-body">
                    注:确定后 删除MYSQL当天数据 (时间稍长,请耐心等待)

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <a class="btn btn-danger"  href="{{route('goods.delete.Data')}}">删除</a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
@endsection

